#!/bin/bash

[ ${MYSQL_REMOTE_CAN_ACCESS} == NO ] && exit 1
SQL_FILE=${APP_OUTPUT_DIR}/remote_can_access_temp.sql
PASSWORD=$1
echo 'grant all privileges on *.* to root@"%"' "identified by '${PASSWORD}';" >> ${SQL_FILE}
echo "flush privileges;" >> ${SQL_FILE}
mysql -u root --password=${PASSWORD} --connect-expired-password < ${SQL_FILE}
! [ ${MYSQL_SAVE_SQL_TEMP} == YES ] && rm -rf ${SQL_FILE}